
<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>

<%@page import="com.tss.util.*"%>
<%@page import="com.jedi.*"%>
<%@page import="com.store.*"%>
<%@page import="java.util.*"%>
<%@page import="java.text.*"%>
<%@include file="../global_var.jsp"%>
<%@include file="../check_login.jsp"%>
<%
String path = request.getContextPath();
String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";
User just_user = (User)session.getAttribute("LoginUser");

String nowyear = new SimpleDateFormat("yyyy").format(Calendar.getInstance().getTime());
String nowmonth = new SimpleDateFormat("MM").format(Calendar.getInstance().getTime());
%>

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>

<head>
    <base href="<%=basePath%>">
    
<title>My JSP 'techcontract_add.jsp' starting page</title>
    
    <meta http-equiv="pragma" content="no-cache">
    <meta http-equiv="cache-control" content="no-cache">
    <meta http-equiv="expires" content="0">
    <meta http-equiv="keywords" content="keyword1,keyword2,keyword3">
    <meta http-equiv="description" content="This is my page">
    <link href="style/main.css" rel="stylesheet" type="text/css">
	<script language="javascript" src="js/common.js"></script>
<%
 String strErr = "";
 String tripfeenum= ParamUtils.getParameter(request,"tripfeenum","0.00");
int taskid       = ParamUtils.getIntParameter(request,"taskid",0);

int worktime     = ParamUtils.getIntParameter(request,"worktime",0);
String spartfee          = ParamUtils.getParameter(request,"spartfee","0.00");
String outefee             = ParamUtils.getParameter(request,"outefee","0.00");
int monthin             = ParamUtils.getIntParameter(request,"monthin",1);
String tripfee             = ParamUtils.getParameter(request,"tripfee","0.00");
if ( !tripfee.trim().equals("0.00")) tripfeenum=tripfee;
   
 String cmd = ParamUtils.getParameter(request,"cmd","");
String year = ParamUtils.getParameter(request,"year",nowyear);
String month = ParamUtils.getParameter(request,"month",nowmonth);

if (cmd.trim().equals("insert")) {
	if (strErr.trim().equals("") && taskid==0) {
		strErr = "工单编号不能为空!";
	}
	
	
	
	if (strErr.trim().equals("")) {
		try {
			Float.parseFloat(spartfee);
		}
		catch(Exception ex) {
			strErr = "备件成本数值输入错误!";
		}
	}
	if (strErr.trim().equals("")) {
		try {
			Float.parseFloat(outefee);
		}
		catch(Exception ex) {
			strErr = "外部人员技术成本!";
		}
	}
	if (strErr.trim().equals("")) {
		try {
			Float.parseFloat(tripfee);
		}
		catch(Exception ex) {
			strErr = "差旅费!";
		}
	}
	

	if (strErr.trim().equals("")) {
	
		Pal pal = new Pal();		
		pal.setTaskid(taskid);
	
		pal.setWorktime( worktime);
		
		pal.setSpartfee(Double.parseDouble( spartfee));
		pal.setOutefee(Double.parseDouble( outefee));
		pal.setTripfee(Double.parseDouble( tripfee));
		pal.setY( Integer.parseInt(year));
		pal.setM( Integer.parseInt(month));
		pal.setCreateman(just_user.getId());
		pal.setMonthin(monthin);
		
		pal.insert();
	if (pal.hasErr()) strErr = pal.getErrHtml();
                
	}
}
      
    
    %>
   <script language="javascript" >
   function clk_submit() {
	var oForm = document.operatorForm;
	oForm.cmd.value = "insert";
	return true;
}

</script>
</head>

<body  leftmargin="0" topmargin="0" marginwidth="0" marginheight="0">
<table width="100%" border="0" cellpadding="0" cellspacing="0">
  <tr>
    <td >
     <form name="operatorForm" method="post" onSubmit="return clk_submit();">
      <table width="100%" border="0" cellspacing="0" cellpadding="0">
        <tr> 
          <td height="100" align="center" valign="top" style="padding-top:10px;padding-bottom:10px;">
            <table width="98%" border="0" cellpadding="1" cellspacing="1" bgcolor="#000000">
			
			 <tr>
                <td height="24" colspan="7" bgcolor="#EDEDF0" style="padding-left:10px;">
                提示：<font color="red">*</font> 号为必填项，请您认真填写                </td>
              </tr>
               <%if (!strErr.trim().equals("")) {%>
              <tr> 
                <td height="24" colspan="7" bgcolor="#D7D7DB" style="padding-left:10px;">
                  错误提示：
                 
                  <font color=red><%=strErr%></font>                </td>
              </tr>
              <%}%>
              
              <tr> 
                <td height="24" colspan="7" bgcolor="#858585" style="padding-left:10px;">
                  <font color="#FFFFFF"><strong>合同信息</strong></font>  </td>
              </tr>
              <tr> 
                <td width="17%" height="24" align="right" bgcolor="#D7D7DB" style="padding-right:5px;">
                <span style="padding-left:5px;"><font color="red">*</font></span>工单编号：</td>
                <td width="83%" colspan="6" bgcolor="#EDEDF0" style="padding-left:5px;">
                  <input name="conid" type="text" value="<%=taskid%>" size="30" maxlength="50" readonly="readonly">
                   &nbsp;&nbsp;</td>
              </tr>
			  
              <tr> 
                <td height="24" align="right" bgcolor="#D7D7DB" style="padding-right:5px;"> 工时(天)：</td>
                <td colspan="6" bgcolor="#EDEDF0" style="padding-left:5px;"> 
                 <input name="worktime" type="text" value="<%=worktime%>" size="20" maxlength="25" class="inputbox"> 天</td>
              </tr>
			  <tr>
                   <td height="24" align="right" bgcolor="#D7D7DB" style="padding-right:5px;" >备件成本：</td>
                   <td bgcolor="#EDEDF0" style="padding-left:5px;" colspan="6" >
                   <input name="spartfee" type="text" value="<%=spartfee%>" id="spartfee" size="35" maxlength="100"> ￥
                   
                   </td>
                
              </tr> 
               <tr>
                   <td height="24" align="right" bgcolor="#D7D7DB" style="padding-right:5px;" >外部人员技术成本：</td>
                   <td bgcolor="#EDEDF0" style="padding-left:5px;" colspan="6" >
                   <input name="outefee" type="text" value="<%=outefee%>" id="outefee" size="25" maxlength="25"> ￥
                   
                   </td>
                
              </tr> 
              <tr>
                   <td height="24" align="right" bgcolor="#D7D7DB" style="padding-right:5px;" >差旅费：</td>
                   <td bgcolor="#EDEDF0" style="padding-left:5px;" colspan="6" >
                   <input name="tripfee" type="text" value="<%=tripfeenum%>" id="tripfee" size="25" maxlength="25"> ￥
                   
                   </td>
                
              </tr> 
              <tr>
                   <td height="24" align="right" bgcolor="#D7D7DB" style="padding-right:5px;" >本月是否有收入：</td>
                   <td bgcolor="#EDEDF0" style="padding-left:5px;" colspan="6" >
                 <select name="monthin" >
                 <option value="1" <%if(monthin==1){%>selected<%}%>>有收入</option>
                 <option value="2" <%if(monthin==2){%>selected<%}%>>无收入</option>
                   </td>
                
              </tr> 
            
                <tr>
                  <td height="24" align="right" bgcolor="#D7D7DB" style="padding-right:5px;"><p>核算年：</p>   
				 </td>
                  <td bgcolor="#EDEDF0" style="padding-left:5px;" colspan="6">
				  <select name="year">
		  <option value="" <%if (year.trim().equals("")){%> selected<%}%>>全部</option>
                    <%
                    int yearNum = Calendar.getInstance().get(Calendar.YEAR)+4;
                    for(int i= yearNum - 10;i <= yearNum;i++) {
                    %>
                    <option value="<%=i%>"<%if (year.trim().equals(i+"")){%> selected<%}%>><%=i%></option>
                    <%}%>
                  </select> 年 &nbsp; 
                  <select name="month">
                  <option value="" <%if (month.trim().equals("")){%> selected<%}%>>全部</option>
                    <option value="01"<%if (month.trim().equals("01")){%> selected<%}%>>一月</option>
                    <option value="02"<%if (month.trim().equals("02")){%> selected<%}%>>二月</option>
                    <option value="03"<%if (month.trim().equals("03")){%> selected<%}%>>三月</option>
                    <option value="04"<%if (month.trim().equals("04")){%> selected<%}%>>四月</option>
                    <option value="05"<%if (month.trim().equals("05")){%> selected<%}%>>五月</option>
                    <option value="06"<%if (month.trim().equals("06")){%> selected<%}%>>六月</option>
                    <option value="07"<%if (month.trim().equals("07")){%> selected<%}%>>七月</option>
                    <option value="08"<%if (month.trim().equals("08")){%> selected<%}%>>八月</option>
                    <option value="09"<%if (month.trim().equals("09")){%> selected<%}%>>九月</option>
                    <option value="10"<%if (month.trim().equals("10")){%> selected<%}%>>十月</option>
                    <option value="11"<%if (month.trim().equals("11")){%> selected<%}%>>十一月</option>
                    <option value="12"<%if (month.trim().equals("12")){%> selected<%}%>>十二月</option>
                  </select>
				  &nbsp;</td>
                </tr>
              <tr> 
                <td bgcolor="#EDEDF0" colspan="7" align="center">
                  <input type="submit" name="submit" value="提 交" class="inputButton"> 
                  <input type="reset" name="reset" value="重 写" class="inputButton">    
                  <input type="hidden" name="cmd" value="">              </td>
              </tr>
            </table>
          </td>
        </tr>
       
      </table>
      </form>
    </td>
  </tr>
</table>

<%if (cmd.equals("insert") && strErr.trim().equals("")){%>
<script language="javascript">
alert("信息添加成功系统将返回首页!");
parent.location.href="analysis_main.jsp";
</script>
<%}%>
<iframe width="168" height="190" name="gToday:normal:agenda.js" id="gToday:normal:agenda.js" src="calendar/ipopeng.htm" scrolling="no" frameborder="0"
			style="BORDER-RIGHT:2px ridge; BORDER-TOP:2px ridge; Z-INDEX:999; LEFT:-500px; VISIBILITY:visible; BORDER-LEFT:2px ridge; BORDER-BOTTOM:2px ridge; POSITION:absolute; TOP:0px">
</iframe>
</body>
</html>
